import type { Module } from 'vuex'
import lkfRequest from '@/services'
import { IRootState } from '../types'
import { IDjradio } from './types'
/* 电台store */
const djradio: Module<IDjradio, IRootState> = {
  namespaced: true,
  state() {
    return {
      cateList: [],
      djradioList: []
    }
  },
  getters: {},
  mutations: {
    getCateListGetter(state, list) {
      state.cateList = list
    },
    getDjradioListGetter(state, list) {
      state.djradioList = list
    }
  },
  actions: {
    /* 请求数据 */
    async getCateistAction({ commit }) {
      const list = await lkfRequest.get({
        url: `/dj/catelist`
      })
      commit('getCateListGetter', list.categories)
    },
    async getDjradioListAction({ commit }, playload) {
      const list = await lkfRequest.get({
        url: `/dj/recommend/type?type=${playload.id}`
      })
      commit('getDjradioListGetter', list.djRadios)
    }
  }
}
export default djradio
